<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title">编辑发货箱数</h4>
</div>
<form id="total_box-form" action="/xqc/delivery/fba-ajax" method="post">
    <div class="modal-body">
        <div style="margin-bottom: 10px;">发货单号：{{ $delivery->delivery_no }}</div>
        <div class="row">
            <div>
                <label for="total_box" style="padding-top: 8px;text-align: right;" class="col-sm-2 control-label">发货箱数</label>
                <div class="col-sm-3">
                    <input type="text" class="form-control total_box_" id="total_box" name="param[total_box]" value="{{ $delivery->total_box ?: ''}}" placeholder="发货箱数" required>
                </div>
                {{ csrf_field() }}
                <input type="hidden" name="param[id]" value="{{ $id }}">
                <input type="hidden" name="action" value="doPrepared">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-primary">提交</button>
            </div>
        </div>
        <div class="box-body table-responsive no-padding">
            <table class="table">
                <thead>
                <tr>
                    <th>SKU总数</th>
                    <th>产品总件数</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>{{ $delivery->total_sku }}</td>
                    <td>{{ $delivery->total_unit }}</td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="box-body table-responsive no-padding">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>SKU</th>
                    <th width="25%">产品名称</th>
                    <th>亚马逊SKU</th>
                    <th>ASIN</th>
                    <th>FNSKU</th>
                    <th>申请发货数量</th>
                    <th>已备货数量</th>
                </tr>
                </thead>
                <tbody>
                @foreach($delivery->detail as $k => $item)
                    <tr>
                        <td>{{ $item->sku->psku_code ?? '' }}</td>
                        <td>{{ $item->sku->psku_cn ?? '' }}</td>
                        <td>{{ $item->seller_sku }}</td>
                        <td>{{ $item->asin }}</td>
                        <td>{{ $item->fnsku }}</td>
                        <td>{{ $item->apply_num }}</td>
                        <td><span class="label label-{{ $item->apply_num > $item->ship_num ? 'danger' : 'info'}}">{{ $item->ship_num }}</span></td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    </div>
</form>
<script language="JavaScript" type="text/javascript">
    $(function () {
        $(".total_box_").inputmask("integer",
            {
                onKeyValidation: function () {
                    if($(this).val()<= 0){
                        $(this).val('');
                    }
                }
            }
        );

        $("#total_box-form").ajaxForm(function (data) {
            if (typeof data === 'object') {
                if (data.status) {
                    $("#listCommonModal").modal('hide');
                    $(".modal-backdrop").remove();
                    $('body').removeClass('modal-open');
                    toastr.success('提交成功 !');
                    $.pjax.reload('#pjax-container');
                } else {
                    swal(data.message, '', 'error');
                }
            }
        });
    });
</script>
